package minh.bac.wcbrazil2014;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.Window;
import android.widget.Button;

public class Dialog_Exit extends Dialog implements
		android.view.View.OnClickListener {

	public Button yes, no;
	public Context context;

	public Dialog_Exit(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		this.context = context;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setBackgroundDrawable(
				new ColorDrawable(android.graphics.Color.TRANSPARENT));
		setContentView(R.layout.custom_dialog_exit);

		yes = (Button) findViewById(R.id.btn_yes);
		no = (Button) findViewById(R.id.btn_no);

		yes.setOnClickListener(this);
		no.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		// switch (v.getId()) {
		// case R.id.btn_yes:
		// dismiss();
		// ((ActionBarActivity)context).finish();
		// //sao lại actionbarActivity?
		// break;
		// case R.id.btn_no:
		// dismiss();
		// break;
		// default:
		// break;
		// }

		int id = v.getId();
		if (id == R.id.btn_yes) {
			dismiss();
			((ActionBarActivity) context).finish();
		} else if (id == R.id.btn_no) {
			dismiss();
		} else
			dismiss();
	}
}
